package com.ethan.http;


import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.google.common.collect.Lists;

import java.net.URLEncoder;
import java.util.List;

/**
 * @author ethan
 * create 2018-04-24 下午3:36
 * desc
 **/
public class HttpTest3 {
    public static void main(String[] args){

        //Object obj = JSON.parse("[\"[{\\\"qmallParentOrderNo\\\":\\\"xep180402142952924\\\",\\\"totalPrice\\\":\\\"29.00\\\",\\\"orderType\\\":1,\\\"saleSource\\\":\\\"mergePage\\\",\\\"qmallSubOrderNo\\\":\\\"581511590350\\\"}]");


//        String params ="\n" +
////                "\"{\"qmallOrders\":[\"[{\\\"qmallParentOrderNo\\\":\\\"xep180402142952924\\\",\\\"totalPrice\\\":\\\"29.00\\\",\\\"orderType\\\":1,\\\"saleSource\\\":\\\"mergePage\\\",\\\"qmallSubOrderNo\\\":\\\"581511590350\\\"}]\"],\"from\":[\"567\"],\"orderNo\":[\"xep180402142952924\"]}\"";
////

        List<QmallEntityProduct> list = Lists.newArrayList();
        QmallEntityProduct qmallEntityProduct = new QmallEntityProduct();
        qmallEntityProduct.setOrderType(1);
        qmallEntityProduct.setQmallParentOrderNo("xep180425161845008");
        qmallEntityProduct.setQmallSubOrderNo("581511590350");
        qmallEntityProduct.setTotalPrice("29.00");
        qmallEntityProduct.setSaleSource("mergePage");
        qmallEntityProduct.setInsuranceType("flightdelay_orderno");
        list.add(qmallEntityProduct);
        String json = JSON.toJSONString(list);

        String url ="http://l-noahkmdpr6dk1.auto.beta.cn0.qunar.com:8080/tts4mobile/addQmallInfoToExt.do?" +
                "orderNo=xep180425161845008&qmallOrders="+ URLEncoder.encode(json);

        String result = HttpUtils2.get(url);


        String str ="";
    }

    private static class QmallEntityProduct {
        /**
         * 辅营父订单号
         */
        private String qmallParentOrderNo;
        /**
         * 辅营子订单号
         */
        private String qmallSubOrderNo;
        /**
         * 用户支付总价
         */
        private String totalPrice;

        /**
         * 订单类型 0:X 1:保险
         */
        private int orderType;

        /**
         * 售卖类型  SaleSourceEnum
         */
        private String saleSource;

        /**
         * 保险类型
         */
        private String insuranceType;

        public String getInsuranceType() {
            return insuranceType;
        }

        public void setInsuranceType(String insuranceType) {
            this.insuranceType = insuranceType;
        }

        public int getOrderType() {
            return orderType;
        }

        public void setOrderType(int orderType) {
            this.orderType = orderType;
        }

        public String getSaleSource() {
            return saleSource;
        }

        public void setSaleSource(String saleSource) {
            this.saleSource = saleSource;
        }

        public String getQmallParentOrderNo() {
            return qmallParentOrderNo;
        }

        public void setQmallParentOrderNo(String qmallParentOrderNo) {
            this.qmallParentOrderNo = qmallParentOrderNo;
        }

        public String getQmallSubOrderNo() {
            return qmallSubOrderNo;
        }

        public void setQmallSubOrderNo(String qmallSubOrderNo) {
            this.qmallSubOrderNo = qmallSubOrderNo;
        }

        public String getTotalPrice() {
            return totalPrice;
        }

        public void setTotalPrice(String totalPrice) {
            this.totalPrice = totalPrice;
        }

        @Override
        public String toString() {
            return "QmallEntityProduct{" +
                    "qmallParentOrderNo='" + qmallParentOrderNo + '\'' +
                    ", qmallSubOrderNo='" + qmallSubOrderNo + '\'' +
                    ", totalPrice='" + totalPrice + '\'' +
                    '}';
        }
    }
}


